package com.tianyi.primeval.data;

import cn.mmf.slashblade_addon.SlashBladeAddon;
import cn.mmf.slashblade_addon.data.SlashBladeAddonBuiltInRegistry;
import cn.mmf.slashblade_addon.registry.SBASlashArtsRegistry;
import cn.mmf.slashblade_addon.registry.SBASpecialEffectsRegistry;
import com.tianyi.origin.block.ModBlocks;
import com.tianyi.origin.item.ModItems;
import com.tianyi.primeval.Primeval;
import com.tianyi.primeval.registry.PLEntiteRegristrys;
import com.tianyi.primeval.registry.PLslashArtRegsitry;
import mods.flammpfeil.slashblade.SlashBlade;
import mods.flammpfeil.slashblade.data.builtin.SlashBladeBuiltInRegistry;
import com.tianyi.primeval.registry.PLSpecialEffectsRegistry;
import mods.flammpfeil.slashblade.init.SBItems;
import mods.flammpfeil.slashblade.recipe.RequestDefinition;
import mods.flammpfeil.slashblade.recipe.SlashBladeIngredient;
import mods.flammpfeil.slashblade.recipe.SlashBladeShapedRecipeBuilder;
import mods.flammpfeil.slashblade.registry.slashblade.EnchantmentDefinition;
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.ItemLike;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.crafting.conditions.IConditionBuilder;
import net.minecraftforge.registries.ForgeRegistries;
import twilightforest.init.TFItems;

import java.util.function.Consumer;

import static com.tianyi.primeval.data.SRelicBuiltInRegsitry.getEnchantmentID;

public class SrelicBladeRecipeProvioder extends RecipeProvider implements IConditionBuilder {
    public SrelicBladeRecipeProvioder(PackOutput output) {
        super(output);
    }

    protected void buildRecipes(Consumer<FinishedRecipe> consumer){
        //示例
        //SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.JINYUAN.location())
                //.pattern("ABA")
                //.pattern("CDE")
                //.pattern("ABA")
                //.define('B',  Items.NETHER_STAR)
                //.define('A',  SBItems.proudsoul_crystal)
                //.define('D',  SlashBladeIngredient.of(
                //        RequestDefinition.Builder.newInstance()
                //                .name(SRelicBuiltInRegsitry.BLADE.location())
                //                .killCount(9000)
                //                .refineCount(40)
                //                .addEnchantment(new EnchantmentDefinition(getEnchantmentID(Enchantments.FIRE_ASPECT),1))
                //                .build()))
                //.define('C',Items.BLAZE_ROD)
                //.define('E',  Items.DIAMOND_BLOCK)
                //.unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.VOID.location())
        .pattern("CBC")
        .pattern("BAB")
        .pattern("CBC")
        .define('B',  Items.PAPER)
        .define('A',  SBItems.slashblade_wood)
        .define('C',  SBItems.proudsoul_tiny)
        .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.MOYING.location())
        .pattern("FBE")
        .pattern("ADA")
        .pattern("GBF")
        .define('B',  Items.COAL_BLOCK)
        .define('A',  Items.BLAZE_ROD)
        .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.VOID.location())//name后面的引用要正确！
                                .killCount(2000)
                                .proudSoul(3000)
                                .refineCount(10)
                                .build()))
        .define('G',ModItems.SHANYAO.get())
        .define('F',Items.BONE_MEAL)
        .define('E',ModItems.YEGUANG.get())
        .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.DANCE_LIGHT.location())
                .pattern("BCB")
                .pattern("ADA")
                .pattern("BCB")
                .define('B',  ModItems.GUANG.get())
                .define('A',  Items.EXPERIENCE_BOTTLE)
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.VOID.location())
                                .killCount(500)
                                .proudSoul(1500)
                                .refineCount(5)
                                .build()))
                .define('C',ModItems.SHANYAO.get())
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.SUKURA.location())
                .pattern("BAB")
                .pattern("ADA")
                .pattern("BAB")
                .define('B',  ModBlocks.YINGK.get())
                .define('A',  ModItems.YINGHUA.get())
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.VOID.location())
                                .killCount(50)
                                .refineCount(1)
                                .build()))
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.WIND.location())
                .pattern("FBF")
                .pattern("ADA")
                .pattern("FBF")
                .define('B',  SBItems.slashblade)
                .define('A',  ModItems.TIANKONG.get())
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.VOID.location())
                                .killCount(1000)
                                .proudSoul(3000)
                                .refineCount(5)
                                .build()))
                .define('F',Items.DIAMOND)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.STRONG_WIND.location())
                .pattern("FBF")
                .pattern("ADA")
                .pattern("FGF")
                .define('B',  SBItems.slashblade)
                .define('A',  Items.DIAMOND_BLOCK)
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.WIND.location())
                                .killCount(5500)
                                .proudSoul(6000)
                                .refineCount(20)
                                .build()))
                .define('F',ModItems.TIANKONG.get())
                .define('G',Items.ELYTRA)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.YANG.location())
                .pattern("FFF")
                .pattern("ADA")
                .pattern("BGB")
                .define('F',  ModItems.YANG.get())
                .define('A',  Items.ENCHANTED_GOLDEN_APPLE)
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.VOID.location())
                                .killCount(500)
                                .proudSoul(1000)
                                .refineCount(10)
                                .build()))
                .define('B',Items.GOLD_INGOT)
                .define('G',Items.GOLD_BLOCK)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.YIN.location())
                .pattern("FAF")
                .pattern("CDC")
                .pattern("BBB")
                .define('F',SBItems.proudsoul_sphere)
                .define('A',  Items.NETHERITE_INGOT)
                .define('C',  Items.ANCIENT_DEBRIS)
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.VOID.location())
                                .killCount(500)
                                .proudSoul(1000)
                                .refineCount(10)
                                .build()))
                .define('B',  ModItems.YIN.get())
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.FALLING_STAR.location())
                .pattern("BAB")
                .pattern("HDN")
                .pattern("BFB")
                .define('B',  Items.LAPIS_LAZULI)
                .define('A',  Items.EMERALD_BLOCK)
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.VOID.location())
                                .killCount(3550)
                                .proudSoul(6000)
                                .refineCount(30)
                                .build()))
                .define('H',Items.GOLD_BLOCK)
                .define('N',Items.DIAMOND_BLOCK)
                .define('F',  ModItems.XINGZHEN.get())
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.XUESE.location())
                .pattern("BAB")
                .pattern("BDB")
                .pattern("FFF")
                .define('B',  Items.REDSTONE_BLOCK)
                .define('A',  ModItems.KUWEI.get())
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.VOID.location())
                                .killCount(4444)
                                .proudSoul(10000)
                                .refineCount(15)
                                .build()))
                .define('F',  ModItems.XIEJIED.get())
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.CAIJUE.location())
                .pattern("FAF")
                .pattern("BDB")
                .pattern("FCF")
                .define('B',  Items.DIAMOND_SWORD)
                .define('A',  Items.HEART_OF_THE_SEA)
                .define('D',  Items.CAKE)
                .define('F',Items.GLASS_BOTTLE)
                .define('C',  Items.WATER_BUCKET)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.JIXU.location())
                .pattern(" A ")
                .pattern("BFB")
                .pattern(" D ")
                .define('B',  ModItems.YINYANG.get())
                .define('A',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.YIN.location())
                                .killCount(3500)
                                .proudSoul(12000)
                                .refineCount(10)
                                .build()))
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.YANG.location())
                                .killCount(3500)
                                .proudSoul(12000)
                                .refineCount(10)
                                .build()))
                .define('F',Items.NETHER_STAR)
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.YINYANG.location())
                .pattern("CNF")
                .pattern("AFD")
                .pattern("ENC")
                .define('E',  ModItems.YANG.get())
                .define('N',  ModItems.YINYANG.get())
                .define('C',  Items.NETHERITE_BLOCK)
                .define('A',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.YIN.location())
                                .killCount(2500)
                                .proudSoul(1000)
                                .refineCount(45)
                                .build()))
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.YANG.location())
                                .killCount(2500)
                                .proudSoul(1000)
                                .refineCount(45)
                                .build()))
                .define('F',  ModItems.YIN.get())
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.MIRACLE.location())
                .pattern("BEB")
                .pattern("CDC")
                .pattern("FAF")
                .define('B',  ModItems.XUANCAID.get())
                .define('A',  Items.DRAGON_EGG)
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.VOID.location())
                                .killCount(1500)
                                .proudSoul(60000)
                                .refineCount(150)
                                .build()))
                .define('C',Items.NETHERITE_BLOCK)
                .define('F',Items.NETHER_STAR)
                .define('E',  ModItems.QIJI.get())
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.SHIYUAN.location())
                .pattern("BCB")
                .pattern("CDC")
                .pattern("FCF")
                .define('B',  ModItems.EXPRO.get())
                .define('F',  Items.NETHER_STAR)
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.FALLING_STAR.location())
                                .killCount(3500)
                                .proudSoul(6000)
                                .refineCount(10)
                                .build()))
                .define('C',ModItems.XINGZHEN.get())
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);

        SlashBladeShapedRecipeBuilder.shaped(SRelicBuiltInRegsitry.SHIYUANEX.location())
                .pattern("BCB")
                .pattern("CDC")
                .pattern("BCB")
                .define('B',  ModItems.XINGZHEN.get())
                .define('D',  SlashBladeIngredient.of(
                        RequestDefinition.Builder.newInstance()
                                .name(SRelicBuiltInRegsitry.SHIYUAN.location())
                                .killCount(6500)
                                .proudSoul(10000)
                                .refineCount(20)
                                .build()))
                .define('C',ModItems.XUANCAID.get())
                .unlockedBy(getHasName(SBItems.slashblade), has(SBItems.slashblade)).save(consumer);
    }


    public Item getItem(ResourceLocation item) {
        return ForgeRegistries.ITEMS.getValue(item);
    }
}
